/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-07-30
 * Time: 22:37
 */
public class test4 {
    public boolean searchMatrix(int[][] matrix, int target) {
        for(int[] row:matrix){
            int index = search(row,target);
            if(index>=0){
                return true;
            }
        }
        return false;
    }

    public int search(int[] nums,int target){
        int left = 0,right = nums.length-1;
        while(left<=right){
            int mid = (right-left)/2 + left;
            if(nums[mid] == target){
                return mid;
            }else if(nums[mid]>target){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }
        return -1;
    }
}
